from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
from meiduo_admin.serializers.users import AdminAuthSerializers

class AdminAuthorizations(APIView):
    def post(self,request):
        """
        管理员登录:
        1. 获取参数并进行校验
        2. 服务器签发jwt token数据
        3. 返回应答
        """
        '''1获取参数并进行校验'''
        serializer = AdminAuthSerializers(data=request.data)
        serializer.is_valid(raise_exception=True)

        '''2. 服务器签发jwt token数据'''
        serializer.save()
        '''3. 返回应答'''
        return Response(serializer.data,status=status.HTTP_201_CREATED)